package org.insia.smartposse.metier;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import org.insia.smartposse.metier.webservice.LightUser;
import org.insia.smartposse.utils.PasswordEncoder;


/**
 * Business class for user.
 * 
 * @author sok hout
 *
 */
public class User 
implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4364487717528733659L;
	protected long _id = -1L;
	protected String _login;
	protected String _password;
	protected String _firstName;
	protected String _lastName;
	protected int _gender;
	protected String _email;
	protected Set<Project> _projectSet = new HashSet<Project>();
	
	/**
	 * Empty constructor for User
	 *
	 */
	public User() {	
	}

	/**
	 * @param id
	 * @param login
	 * @param password
	 * @param firstName
	 * @param lastName
	 * @param gender
	 * @param email
	 */
	public User(Long id, String login, String password, String firstName, String lastName, int gender, String email) {
		this._id = id;
		this._login = login;
		this._password = PasswordEncoder.encode(password);
		_firstName = firstName;
		_lastName = lastName;
		this._gender = gender;
		this._email = email;
	}

	/**
	 * Getter for the set of projects.
	 * @return the set of projects.
	 */
	public Set<Project> getProjectSet() {
		return _projectSet;
	}


	/**
	 * Setter for the set of projects.
	 * @param projectSet the set of projects to set.
	 */
	public void setProjectSet(Set<Project> projectSet) {
		this._projectSet = projectSet;
	}
	
	/**
	 * Getter for the email.
	 * @return the email.
	 */
	public String getEmail() {
		return _email;
	}

	/**
	 * Setter for the email.
	 * @param email
	 */
	public void setEmail(String email) {
		this._email = email;
	}

	/**
	 * Getter for the first name.
	 * @return the first name.
	 */
	public String getFirstName() {
		return _firstName;
	}

	/**
	 * Setter for the first name.
	 * @param firstName the first name to set.
	 */
	public void setFirstName(String firstName) {
		this._firstName = firstName;
	}

	/**
	 * Getter for the gender.
	 * @return the gender.
	 */
	public int getGender() {
		return _gender;
	}

	/**
	 * Setter for the gender.
	 * @param gender the gender to set.
	 */
	public void setGender(int gender) {
		this._gender = gender;
	}

	/**
	 * Getter for the id.
	 * @return the id to set.
	 */
	public long getId() {
		return _id;
	}

	/**
	 * Setter for the id.
	 * @param id the id to set.
	 */
	public void setId(long id) {
		this._id = id;
	}

	/**
	 * Getter for the last name.
	 * @return the last name.
	 */
	public String getLastName() {
		return _lastName;
	}

	/**
	 * Setter for the last name.
	 * @param lastName the last name to set.
	 */
	public void setLastName(String lastName) {
		this._lastName = lastName;
	}

	/**
	 * Getter for the login.
	 * @return the login.
	 */
	public String getLogin() {
		return _login;
	}

	/**
	 * Setter for the login
	 * @param login the login to set.
	 */
	public void setLogin(String login) {
		this._login = login;
	}

	/**
	 * Getter for the password.
	 * @return the password.
	 */
	public String getPassword() {
		return _password;
	}

	/**
	 * Setter for the password.
	 * @param password the password to set.
	 */
	public void setPassword(String password) {
		this._password = password;
	}
	/**
	 * 
	 * @return lcatet the webservice User representation
	 */
	public LightUser setLight() {
		LightUser luser = new LightUser(this);
		return luser;
	}
	
}
